import request from '@/utils/request2'
import qs from 'qs'


/**
 * 获取流水号
 * @param data
 */
export function getserialNo(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/sys/serialNo/listJson',
    method: 'post',
    data: qs.stringify(data)
  })
}



/**
 * 获取一级分类
 * @param data
 */
export function getRootCategory(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/data/api/list/all',
    method: 'post',
    data: qs.stringify(data)
  })
}



/**
 * 根据id 获取 获取一级分类
 * @param id
 */
export function getRootCategoryById(id) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/data/api/get/'+id,
    method: 'GET',
  })
}
export function getCategoryByParentId(id) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/data/api/category/getByParentId/'+id,
    method: 'GET',
  })
}


/**
 * 保存一级分类
 * @param data
 */
export function saveRootCategory(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/data/api/category/save',
    method: 'post',
    data: JSON.stringify(data)
  })
}

/**
 * 更新资源
 * @param data
 */
export function updateResource(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/sys/menu/update',
    method: 'post',
    data: JSON.stringify(data)
  })
}
export function removeResource(id) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/sys/menu/remove/'+id,
    method: 'post'
  })
}
/**
 * 保存资源
 * @param data
 */
export function saveResource(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/sys/menu/save',
    method: 'post',
    data: JSON.stringify(data)
  })
}




/**
 * 删除一级分类
 * @param data
 */
export function removeRootCategory(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/data/api/v2/remove',
    method: 'POST',
    data: data
  })
}


/**
 * 保存序列号
 * @param data
 */
export function saveSerialNo(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/sys/serialNo/save',
    method: 'post',
    data: JSON.stringify(data)
  })
}

/**
 * 获取序列号
 * @param id
 */
export function getSerialNoById(id) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/sys/serialNo/get/'+id,
    method: 'GET',
  })
}
export function getMenuList() {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/sys/menu/list/tree',
    method: 'GET',
  })
}

/**
 * 预览流水号
 * @param id
 */
export function getSerialNoByAlias(id) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/sys/serialNo/previewIden/'+id,
    method: 'GET',
  })
}

/**
 * 移除流水号
 * @param data
 */
export function removeSerialNo(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/sys/serialNo/v2/remove',
    method: 'POST',
    data: data
  })
}



/**
 * 获取租户
 * @param id
 */
export function getTenantList(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/tenant/api/list',
    method: 'POST',
    data: qs.stringify(data)
  })
}
export function getEmailList(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/email/api/list',
    method: 'POST',
    data: qs.stringify(data)
  })
}

/**
 * 获取租户
 * @param id
 */
export function saveTenantList(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'

    },
    url: '/tenant/api/save',
    method: 'POST',
    data: JSON.stringify(data)
  })
}
/**
 * 保存信息管道
 * @param id
 */
export function saveSms(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'

    },
    url: '/sys/sms/save',
    method: 'POST',
    data: JSON.stringify(data)
  })
}

/**
 * 获取租户
 * @param id
 */
export function getTenantById(id) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/tenant/api/get/'+id,
    method: 'POST',
  })
}

export function removeTenant(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/tenant/api/v2/remove',
    method: 'POST',
    data: data
  })
}


/**
 * 获取短信通道列表
 * @param id
 */
export function getSmsList(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/sys/sms/list',
    method: 'POST',
    data: qs.stringify(data)
  })
}

/**
 * 获取sms列表
 * @param id
 */
export function getSmsById(id) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/sys/sms/get/'+id,
    method: 'POST',
  })
}

/**
 * 移除SMS
 * @param data
 */
export function removeSms(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/sys/sms/v2/remove',
    method: 'POST',
    data: data
  })
}

/**
 * 获取短信发送日志
 * @param data
 */
export function getSmsLogList(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/sys/sms/log/list',
    method: 'POST',
    data: qs.stringify(data)
  })
}


/**
 * 获取字典列表
 * @param id
 */
export function getDict(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: 'sys/dict/list',
    method: 'POST',
    data: qs.stringify(data)
  })
}
/**
 * 保存字典列表
 * @param id
 */
export function saveDict(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: 'sys/dict/save',
    method: 'POST',
    data: JSON.stringify(data)

  })
}

export function removeDict(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: 'sys/dict/v2/remove',
    method: 'POST',
    data: data
  })
}



/**
 * 获取字典列表
 * @param id
 */
export function getDictById(id) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: 'sys/dict/get/'+id,
    method: 'POST',
  })
}
/**
 * 获取字典列表项
 * @param id
 */
export function getDictItem(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: 'sys/dict/item/get/dictItem/'+data.dictCode,
    method: 'POST',
    data: qs.stringify(data)
  })
}
/**
 * 保存字典列表
 * @param id
 */
export function saveDictItem(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: 'sys/dict/item/save',
    method: 'POST',
    data: JSON.stringify(data)

  })
}
/**
 * 获取字典列表
 * @param id
 */
export function getDictItemById(id) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: 'sys/dict/item/get/'+id,
    method: 'POST',
  })
}
export function removeDictItem(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: 'sys/dict/item/v2/remove',
    method: 'POST',
    data: data
  })
}
export function getItemByCode(code) {
  return request({
    url: '/sys/dict/item/get/code/'+code,
    method: 'GET',
  })
}
